#!/usr/bin/perl

use strict;
use modules::encode;
package csset;

sub csset {

    my ($dbh,$remote,$input,$csnum,$nsnum) = @_;
    my $sth;my $auth;
    if ($$input[6] eq "") {
	print $remote "$csnum O $$input[0] :Syntax :SET <channel> <option> <args>\n";
    }

#check if auth.
    else {
	$sth=$dbh->prepare("SELECT auth FROM ninfo WHERE code = '".encode::encode($$input[0])."' AND num = '$$input[0]';");
	$sth->execute;
	if (!$sth->fetchrow_array) {
	    print $remote "$csnum O $$input[0] :Please identify yourself with nickserv ($nsnum) before using this command.\n";
	}
	else {
	    $sth=$dbh->prepare("SELECT level FROM users WHERE rnick = '$auth' AND channel = '$$input[4]' AND level >= 450;");
	    $sth->execute;
	    if (!$sth->fetchrow_array) {
		print $remote "$csnum O $$$input[0] :Access denied.\n";
	    }
	    else {
#start the cmds.
		if (lc($$input[5]) eq "strictops") { 
		    if ($$input[6] ne '1' && $$input[6] ne '0') {
			print $remote "$csnum O $$input[0] :Syntax :SET <channel> <option> <args>\n";
		    }
		    else {
			$sth=$dbh->prepare("SELECT strictop");
		    }
		}
	    }
	}
    }
}




